//
//  VIZVistorTableVC.swift
//  VIZ微博
//
//  Created by 位立志 on 16/4/8.
//  Copyright © 2016年 位立志. All rights reserved.
//

import UIKit

class VIZVistorTableVC: UITableViewController , VIZVistorLoginViewDelegate {

    
    //是否登录
//    let isLogin : Bool = false
    //如果有数据就表示已经登录了:数据从用户模型中读取
    let isLogin : Bool = VIZUserViewAccountModel.shardInstance.userInfo != nil
    
    //未登录界面
    var vistorView : VIZVistorLoginView?
    
    //重写loadView
    override func loadView() {
        
        isLogin ? super.loadView() : setView()

    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //设置导航条
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
//        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillReisgin")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "userWillLogin")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "userWillReisgin")
        
        //设置代理对象
        vistorView?.delegate = self
        
    }
    
    
    func userWillLogin() {
        
        //print("VC中登录")
        //创建oauth控制器
        let oauth = VIZOAuthVC()
        //创建导航控制器
        let nav = UINavigationController(rootViewController: oauth)
        //跳转到控制器
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func userWillReisgin() {
        //print("VC中注册")
    }
    
    //自己设置界面
    func setView() {
        
        //设置界面
        vistorView = VIZVistorLoginView()
        
        view = vistorView
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}
